﻿Imports System.Data

Partial Class WebForm_CommonControl_VolunteerQueryControl2
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Me.LoadOnStartUp = True Then
                Me.InitData()
            End If
        End If
    End Sub

    Public Sub InitData()

        '運用單位
        If Me.Admin = True Then
            ddlOrganizationID.DataSource = MyObj.GetDDLReportOrganizationData()
        Else
            ddlOrganizationID.DataSource = clsAuth.GetDDLReportOrganizationData()
        End If

        ddlOrganizationID.DataBind()
        ddlOrganizationID.Items.Insert(0, MyObj.GetDDLSelectAllItem())
    End Sub

    Sub Show_mpSearch()
        If mpSearchUniqueID <> String.Empty Then
            Dim mpSearch As AjaxControlToolkit.ModalPopupExtender = Page.FindControl(mpSearchUniqueID)
            If mpSearch IsNot Nothing Then
                mpSearch.Show()
            End If
        End If
    End Sub

End Class

Partial Class WebForm_CommonControl_VolunteerQueryControl2

    Public ReadOnly Property OrganizationID() As String
        Get
            If ddlOrganizationID.SelectedValue = "" Then
                Return "0"
            Else
                Return ddlOrganizationID.SelectedValue
            End If
        End Get

    End Property

    Public ReadOnly Property OrganizationName() As String
        Get
            If ddlOrganizationID.SelectedValue = "" Then
                Return ""
            Else
                Return ddlOrganizationID.SelectedItem.Text
            End If
        End Get

    End Property

    Public Property mpSearchUniqueID() As String
        Get
            Return ViewState("MpSearchUniqueID")
        End Get
        Set(ByVal value As String)
            ViewState("MpSearchUniqueID") = value
        End Set

    End Property

    Public Property LoadOnStartUp() As Boolean
        Get
            If ViewState("LoadOnStartUp") Is Nothing Then
                Return False
            End If

            Return ViewState("LoadOnStartUp")
        End Get
        Set(ByVal value As Boolean)
            ViewState("LoadOnStartUp") = value
        End Set
    End Property

    Public Property Admin() As Boolean
        Get
            If ViewState("Admin") Is Nothing Then
                Return False
            End If

            Return ViewState("Admin")
        End Get
        Set(ByVal value As Boolean)
            ViewState("Admin") = value
        End Set
    End Property

End Class